Skip to main content

Information

info

Create your dialogue(s) in the folder path: server/dialogues/*.

info

DialogueButtons can have as many sub buttons as you would like.

Type interface

Dialogue
---@class CDialogue
---@field id string Unique ID identifier for the dialogue
---@field name string Ped name
---@field title string Ped title
---@field text string Ped first message like (Hello, What are you doing?. etc.)
---@field buttons IDialogueButton[]

Dialogue:new(id, name, title, text)
Button
---@class IDialogueButton
---@field label string
---@field text? string
---@field event? string
---@field close? boolean
---@field goback? boolean
---@field buttons? IDialogueButton[]
---@field condition? fun(playerId: number): boolean

---@param ctx IDialogueButton
function CreateDialogueButton(ctx)
return ctx
end

Example

Example dialogue
Dialogue:new("example_dialog_id2", "Jane (Item Shop)", "Shopkeeper", "Welcome! How can I assist you?")
:addButton(CreateDialogueButton({
label = "Show me your items for sale.",
close = true,
event = "Talk:Shop:ShowItems"
}))
:addButton(CreateDialogueButton({
label = "Do you have any discounts?",
text = "Yes, we have a special discount on selected items. Check them out!",
buttons = {
CreateDialogueButton({
label = "Great, show me the discounted items.",
close = true,
event = "Talk:Shop:ShowDiscountedItems"
}),
CreateDialogueButton({
label = "I'll take a look, thanks.",
close = true
})
}
}))

RegisterNetEvent("Talk:Shop:ShowItems", function()
local playerId = source
print("Showing items...")
end)
RegisterNetEvent("Talk:Shop:ShowDiscountedItems", function()
local playerId = source
print("Showing discounted items...")
end)